package com.geek.controller;


import com.geek.bean.BaseRespVo;
import com.geek.bean.PageData;
import com.geek.bean.vo.FootprintDeleteVo;
import com.geek.service.FootprintService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/wx/footprint")
public class WxFootprintController {
    @Autowired
    private FootprintService footprintService;
    @GetMapping("list")
    public BaseRespVo list(int page, int limit) {
        Subject subject = SecurityUtils.getSubject();
        if (subject.isAuthenticated()) {
            Integer userId = (Integer) subject.getPrincipal();
            PageData commonData = footprintService.list(userId, page, limit);
            return BaseRespVo.ok(commonData);
        } else {
            return BaseRespVo.unAuthc();
        }
    }
    @PostMapping("delete")
    public BaseRespVo delete(@RequestBody FootprintDeleteVo footprintDeleteVo) {
            Integer id = footprintDeleteVo.getId();
            footprintService.delete(id);
        return BaseRespVo.ok(null);

        }

}